package com.cupk.carManageMaster.core.serviceImpl;

import com.cupk.carManageMaster.common.domain.ResponseBase;
import com.cupk.carManageMaster.core.service.BaseApiService;

/**
 * 名称BaseApiServiceImpl
 * 描述BaseApiService
 *
 * @version 1.0
 * @author:wanghao
 * @datatime:2023,06,01,15,54
 */
public class BaseApiServiceImpl implements BaseApiService {

    @Override
    public ResponseBase setResultError(Integer code, String msg) {
        return setResult(code, msg, null);
    }

    @Override
    // 返回错误，可以传msg
    public ResponseBase setResultError(String msg) {
        return setResult(400, msg, null);
    }

    @Override
    // 返回成功，可以传data值
    public ResponseBase setResultSuccess(Object data) {
        return setResult(200, "success", data);
    }

    @Override
    // 返回成功，沒有data值
    public ResponseBase setResultSuccess() {
        return setResult(200, "success", null);
    }

    @Override
    // 返回成功，沒有data值
    public ResponseBase setResultSuccess(String msg) {
        return setResult(200, msg, null);
    }

    @Override
    // 通用封装
    public ResponseBase setResult(Integer code, String msg, Object data) {
        return new ResponseBase(code, msg, data);
    }

}
